package com.zrrd.springboot_homework.controller;

import com.zrrd.springboot_homework.pojo.Tea;
import com.zrrd.springboot_homework.service.TeaService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title TeaController
 * @description
 * @create 2024/3/23
 */
@RestController
@RequestMapping("/teas")
public class TeaController {
    @Resource
    TeaService teaService;

    @GetMapping
    @ResponseBody
    public List<Tea> queryAll() {
        return teaService.queryAll();
    }

    @GetMapping("/{id}")
    @ResponseBody
    public Tea queryById(@PathVariable Integer id) {
        return teaService.queryById(id);
    }

    @PostMapping
    @ResponseBody
    public Integer add(@RequestBody Tea tea) {
        return teaService.add(tea);
    }

    @PutMapping
    @ResponseBody
    public Integer update(@RequestBody Tea tea) {
        return teaService.add(tea);
    }

    @DeleteMapping("/{id}")
    @ResponseBody
    public Integer remove(@PathVariable Integer id) {
        return teaService.remove(id);
    }
}
